import {LayerUtil} from "../utils/LayerUtil";
import {HttpUtil} from "../utils/HttpUtil";
import {CONST} from "../base/constant";

export const getCategoriesAction = () => {

    const url = CONST.API_PREFIX + "/category";

    return new Promise(function (resolve,reject) {
        HttpUtil.get(url).then(function (txt) {
            if(txt){
                const res = JSON.parse(txt);
                resolve(res);
            }else{
                LayerUtil.toast('接口错误');
            }
        }).catch(function (err) {
            reject(err);
        });
    })

};